﻿using Coldairarrow.Business.View;
using Coldairarrow.Entity.DTO;
using Coldairarrow.Entity.View;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.View
{
    [Route("/View/[controller]/[action]")]
    public class View_PickUpMaterialDetailController : BaseApiController
    {
        #region DI

        public View_PickUpMaterialDetailController(IView_PickUpMaterialDetailBusiness view_PickUpMaterialDetailBus)
        {
            _view_PickUpMaterialDetailBus = view_PickUpMaterialDetailBus;
        }

        IView_PickUpMaterialDetailBusiness _view_PickUpMaterialDetailBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<View_PickUpMaterialDetail>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _view_PickUpMaterialDetailBus.GetDataListAsync(input);
        }
        public async Task<PageResult<View_PickUpMaterialDetail>> GetInventoryDataList(PageInput<QueryGetInventoryDTO> input)
        {
            return await _view_PickUpMaterialDetailBus.GetInventoryDataListAsync(input);
        }
        [HttpPost]
        public async Task<View_PickUpMaterialDetail> GetTheData(IdInputDTO input)
        {
            return await _view_PickUpMaterialDetailBus.GetTheDataAsync(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(View_PickUpMaterialDetail data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _view_PickUpMaterialDetailBus.AddDataAsync(data);
            }
            else
            {
                await _view_PickUpMaterialDetailBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _view_PickUpMaterialDetailBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}